package com.bajiao.service.order;

import com.bajiao.dto.coupon.CouponCountDto;
import com.bajiao.dto.coupon.CouponDto;
import com.bajiao.dto.order.ConfirmOrderRequest;
import com.bajiao.dto.order.CreateOrderRequest;
import com.bajiao.dto.order.EncodeMenuOrderDetails;
import com.bajiao.entity.order.Order;
import com.bajiao.entity.order.OrderDetails;
import com.bajiao.entity.order.RefundOrder;
import com.bajiao.entity.user.User;
import com.bajiao.vo.order.ConfirmOrderResponse;
import com.bajiao.vo.order.OrderAdmin;
import com.bajiao.vo.order.OrderDetailsResponse;
import com.bajiao.vo.order.OrderResponse;
import com.baomidou.mybatisplus.extension.service.IService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Description: 订单表
 * @Author: FanJq
 * @Date:   2024-12-14
 * @Version: V1.0
 */
public interface OrderService extends IService<Order> {

    /**
     * @Description
     * 确认订单
     * @date 2024/12/14 14:33
     * @author FanJq
     * @param request
     * @return {@link Order}
    */
    ConfirmOrderResponse confirm(String userId, ConfirmOrderRequest request);

    ConfirmOrderResponse confirm1(String userId,String couponds, ConfirmOrderRequest request);

    /**
     * @Description
     * 订单中心去支付
     * @date 2025/1/13 18:34
     * @author FanJq
     * @param userId
     * @param request
     * @return {@link ConfirmOrderResponse}
    */
    ConfirmOrderResponse centerConfirm(String userId, ConfirmOrderRequest request);

    /**
     * @Description
     * 创建订单
     * @date 2024/12/14 16:49
     * @author FanJq
     * @param userId
     * @param request
     * @return {@link Order}
    */
    Order create(String userId, CreateOrderRequest request);

    /**
     * @Description
     * 订单支付
     * @date 2024/12/14 16:39
     * @author FanJq
     * @param user
     * @param params
     * @return {@link String}
    */
    Object toPay(User user, CreateOrderRequest params, HttpServletRequest request);

    /**
     * @Description
     * 支付完成
     * @date 2024/12/14 17:21
     * @author FanJq
     * @param order
     * @return
    */
    void complete(Order order);

    /**
     * @Description
     * 获取订单分页列表
     * @date 2024/12/16 16:56
     * @author FanJq
     * @param userId
     * @param status
     * @return {@link List< OrderResponse>}
    */
    List<OrderResponse> getOrderPage(String userId, Integer status);

    /**
     * @Description
     * 取消订单
     * @date 2024/12/16 17:44
     * @author FanJq
     * @param userId
     * @param orderNo
     * @return
    */
    void cancel(String userId, String orderNo);

    /**
     * @Description
     * 申请退款
     * @date 2024/12/19 11:41
     * @author FanJq
     * @param userId
     * @param orderNo
     * @return
    */
    void askRefund(String userId, String orderNo, String reason);

    /**
     * @Description
     * 根据订单编号获取
     * @date 2024/12/16 17:48
     * @author FanJq
     * @param userId
     * @param orderNo
     * @return {@link Order}
    */
    Order getByOrderNo(String userId, String orderNo);

    /**
     * @Description
     * 根据订单编号获取
     * @date 2025/1/13 19:42
     * @author FanJq
     * @param payNo
     * @return {@link Order}
    */
    Order getByPayNo(String payNo);

    /**
     * @Description
     * 获取订单详情
     * @date 2024/12/19 16:18
     * @author FanJq
     * @param userId
     * @param orderNo
     * @return {@link OrderDetailsResponse}
    */
    OrderDetailsResponse getDetails(String userId, String orderNo);

    /**
     * @Description
     * 订单执行退款逻辑
     * @date 2024/12/19 17:27
     * @author FanJq
     * @param refundOrder
     * @return
    */
    void refundLogic(RefundOrder refundOrder, int status);

    /**
     * @Description
     * 扫码核销
     * @date 2024/12/26 14:15
     * @author FanJq
     * @param verifyCode
     * @return {@link String}
    */
    String scanCode(String storeId, String verifyCode);

    /**
     * @Description
     * 管理后台列表
     * @date 2025/1/7 17:39
     * @author FanJq
     * @param orderNo
     * @param keywords
     * @param productTitle
     * @param status
     * @param createTimeBegin
     * @param createTimeEnd
     * @return {@link List< OrderAdmin>}
    */
    List<OrderAdmin> getAdminList(String orderNo, String keywords, String productTitle, Integer status, String createTimeBegin, String createTimeEnd);

    /**
     * @Description
     * 订单统计
     * @date 2025/2/12 11:42
     * @author FanJq
     * @param
     * @return {@link Map< String, Object>}
    */
    Map<String, Object> getOrderStat();

    /**
     * @Description
     * 获取优惠提示
     * @date 2025/1/13 14:41
     * @author FanJq
     * @param userId
     * @param storeId
     * @return {@link String}
    */
    String getDiscountTips(String userId, String storeId);

    /**
     * @Description
     * 计算购物车价格
     * @date 2025/1/13 16:50
     * @author FanJq
     * @param userId
     * @param storeId
     * @param cartIds
     * @return {@link String}
    */
    Map<String, String> getCartAmount(String userId, String storeId, String cartIds);

    /**
     * @Description
     * 订单过期事件
     * @date 2025/2/19 19:01
     * @author FanJq
     * @param order
     * @return
    */
    void expiredEvent(Order order);

    /**
     * 查询当前店铺拥有的优惠劵类型
     */
    List<CouponDto> queryCouponTypeByStore(String userId, String storeId);

    List<CouponCountDto> queryCouponNumber(String userId, String storeId, String cartIds);

    List<EncodeMenuOrderDetails> orderMenuDetails(String userId, String storeId, String cartIds);

}
